/**
* <p>Title: PersistenceManager.java</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2009</p>
* <p>Company: xunjie</p>
* @author shenhao
* @date 2010-3-9
* @version 1.0
*/
package cn.haona.game.simb.object.god;

import java.sql.Connection;

import cn.haona.db.DbcpBean;

/**
 * <p>Title: PersistenceManager</p>
 * <p>Description: </p>
 * <p>Company: xunjie</p> 
 * @author    shenhao
 * @date       2010-3-9
 */
public class PersistenceManager implements Manager
{

	//DB数据源
	private DbcpBean db;
	//SIMB的MYSQL  jdbc:mysql://localhost:3306/simb
	private String connectURI;
	//用户名
	private String username;
	//密码
	private String password;
	//MYSQL: com.mysql.jdbc.Driver
	private String driverClass;
	private int initialSize;//初始连接数 5
	private int maxActive; //最大连接数 100
	private int maxIdle;//最大空闲连接数 30
	private long maxWait;//连接池用完   客户端最大等待的数量 10000
	
	
	/**
	 * 
	 */
	public PersistenceManager()
	{
		// TODO 本地文件记录
	}
	
	/**
	 * 初始化数据库
	 */
	public void initDB()
	{
		db=new DbcpBean();
		db.initDS(connectURI, username, password, driverClass, initialSize, maxActive, maxIdle, maxWait);
	}
	

	/* (non-Javadoc)
	 * <p>Title: getID</p>
	 * <p>Description: </p>
	 * @return
	 * @see cn.haona.game.simb.god.Manager#getID()
	 */

	public String getID()
	{
		// TODO Auto-generated method stub
		return null;
	}

	public void destoryMe()
	{
		// TODO Auto-generated method stub
		
	}

	public void initMe()
	{
		// TODO Auto-generated method stub
		
	}

	
	/**
	 * 得到一条数据库链接
	 * @return
	 */
	public Connection getDB_Connection()
	{
		return db.getConn();
	}
	
	public DbcpBean getDb() {
		return db;
	}


	public String getConnectURI() {
		return connectURI;
	}

	public void setConnectURI(String connectURI) {
		this.connectURI = connectURI;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getDriverClass() {
		return driverClass;
	}

	public void setDriverClass(String driverClass) {
		this.driverClass = driverClass;
	}

	public int getInitialSize() {
		return initialSize;
	}

	public void setInitialSize(int initialSize) {
		this.initialSize = initialSize;
	}

	public int getMaxActive() {
		return maxActive;
	}

	public void setMaxActive(int maxActive) {
		this.maxActive = maxActive;
	}

	public int getMaxIdle() {
		return maxIdle;
	}

	public void setMaxIdle(int maxIdle) {
		this.maxIdle = maxIdle;
	}

	public long getMaxWait() {
		return maxWait;
	}

	public void setMaxWait(long maxWait) {
		this.maxWait = maxWait;
	}

}
